﻿using System;
using System.Collections.Generic;
using System.Text;
using FunctionalCLR.Core;

namespace FunctionalCLR.Core.Function.List {

    /// <summary>
    /// a = [1,3,5,7,9,11];
    /// drop(a, 2);
    /// echo(a);
    /// # result is [1,5,7,9,11];
    /// </summary>
    public class ListDropNode : FuncNode {

        public ListDropNode()
            : base() {
            this.Value = "drop";
        }

        public override FuncNode GetReversedFunction(int index) {
            throw new NotImplementedException();
        }

        public override object Evaluate() {
            ListNode node = (ListNode)Children[0].Evaluate();
            int nth = Convert.ToInt32(Children[1].Evaluate());
            
            object obj = node.Children[nth];
            node.Children.RemoveAt(nth);

            return obj;
        }
    }
}
